<html lang="zh">
	<head>
    <script>
	function Ajax(type, url, data, success, failed){
        var xhr = null;
        if(window.XMLHttpRequest){
            xhr = new XMLHttpRequest();
        } else {
            xhr = new ActiveXObject('Microsoft.XMLHTTP')
        }
        var type = type.toUpperCase();
        var random = Math.random();
     
        if(typeof data == 'object'){
            var str = '';
            for(var key in data){
                str += key+'='+data[key]+'&';
            }
            data = str.replace(/&$/, '');
        }
        if(type == 'GET'){
            if(data){
                xhr.open('GET', url + '?' + data, true);
            } else {
                xhr.open('GET', url + '?t=' + random, true);
            }
            xhr.send();
        } else if(type == 'POST'){
            xhr.open('POST', url, true);
            xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xhr.send(data);
        }
        xhr.onreadystatechange = function(){
            if(xhr.readyState == 4){
                if(xhr.status == 200){
                    success(xhr.responseText);
                } else {
                    if(failed){
                        failed(xhr.status);
                    }
                }
            }
        }
    };
    function getUrlVars() {
        var vars = {};
        var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,    
        function(m,key,value) {
          vars[key] = value;
        });
        return vars;
    };
</script>
</head>
<body style="padding:0;margin:0;">
<div id="loading"> 
<img  id="img" style="display:none;" src="">
</div>
<iframe src="" id="frame" scrolling="no" style="overflow:hidden;border:none;" frameborder="no"></iframe>
<script>
var url=decodeURIComponent(getUrlVars()["url"]);
var sendData = {url:url};
var width=parseInt(getUrlVars()["w"])||800;
var height=parseInt(getUrlVars()["h"])||500;
var frame=document.getElementById('frame');
var imgDiv=document.getElementById('loading');
var img=document.getElementById('img');
var marginTop=(height-114)/2;
marginTop=marginTop>0?marginTop:0;
frame.width=width;
frame.height=height;
imgDiv.style="width:"+width+"px;height:"+height+"px;";
img.style="padding-top:"+marginTop+"px;border:none;width:200px;height:114px;display:block;margin:0 auto;";
var checker=function(){
        Ajax('get', '/ping', sendData, function(data){
            if(data=="1"){
                imgDiv.style="display:none;";
                frame.src=url;
            }else{
             setTimeout(checker,1000);
            }
        }, function(error){
             setTimeout(checker,1000);
        });
    };
checker();
</script>
</body>
</html>